<?php 
	header("Content-type:text/html;charset=utf-8");
	// 连接数据库
	$conn = mysql_connect("localhost","root","root");
	mysql_select_db("test");
	
	$result = mysql_query("select * from goods",$conn);
	if(mysql_num_rows($result) > 0){
		$str = "";
		$s = 0;
		$fh = '"';
		$dh = "";
//         "location":[
//             {
//             "顶部":"3"
//             },{
//             "底部":"1"
//             },{
//             "左侧":"2"
//             },{
//             "右侧":"1"
//             },{
//             "悬浮":"4"
//             }
//  ],

		while($obj = mysql_fetch_assoc($result)){
			// $str = $str . $obj["goods_id"] . ",";
            $str = $str . $dh . $fh . $s . "id" . $fh .":" . $fh . $obj["id"] . $fh;
            $dh = ",";
			$str = $str . $dh . $fh . $s . "text" . $fh .":" . $fh . $obj["introduce"] . $fh;
            $str = $str . $dh . $fh . $s . "money" . $fh .":" . $fh . $obj["price"] . $fh;
            $str = $str . $dh . $fh . $s . "img" .  $fh .":" . $fh . $obj["img"] . $fh;
			
			$s++;
		}
		$str = "{" . $str . "}";
		echo $str;
	}else{
		echo 0;
	}
	mysql_close($conn);
?>